package com.qiji.video.web.controller;

import com.github.pagehelper.PageInfo;
import com.qiji.video.bean.vo.CommentAndUsers;
import com.qiji.video.service.ICommentService;
import com.qiji.video.util.Result;
import com.qiji.video.util.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 评论管理模块
 */
@Api(
        tags = {"评论管理模块"}
)
@RestController
@RequestMapping({"/auth/admin/comments"})
public class CommentController {
    @Autowired
    private ICommentService commentService;
    @ApiOperation("电影id查询评论")
    @GetMapping("/queryComments")
    public Result queryComments(Integer pageNum, Integer pageSize, Integer id, HttpServletRequest request){
        PageInfo<CommentAndUsers> comments=commentService.selectCommentById(pageNum,pageSize,id);
        return ResultUtil.success(comments);
    }
    //评论删除
    @ApiOperation("删除评论")
    @DeleteMapping("/deleteComment")
    public Result deleteComment(Integer id){
        commentService.delete(id);
        return ResultUtil.success();
    }
    //批量删除评论
    @ApiOperation("批量删除评论")
    @DeleteMapping("/deleteComments")
    public Result deleteComments(Integer[] ids){
        commentService.delete(ids);
        return ResultUtil.success();
    }
}
